<template>
  <div class="hospital">
    <div class="hospital-content-head">
      <nuxt-link to="/hospital">
        <div
          class="hospital-content-head-text"
        >
          医院
        </div>
      </nuxt-link>

      <div class="hospital-content-head-icon" />
      <div class="hospital-content-head-detils-text">
        医院主页
      </div>
    </div>
    <div class="hospital-wrap">
      <div class="hospital-content">
        <div class="hospital-content-user-wrap">
          <div class="hospital-content-user-photo-wrap">
            <div
              class="hospital-content-user-photo"
              :style="{background:'url('+hospitalData.user_photo+') center center no-repeat',backgroundSize:'100% 100%'}"
            />
            <nuxt-link rel="nofollow" to="/aboutus">
              <div class="hospital-content-user-consultation">
                立即咨询
              </div>
            </nuxt-link>
          </div>
          <div class="hospital-content-user-data">
            <div class="hospital-content-user-data-wrap">
              <div class="hospital-content-user-data-left">
                <div class="hospital-content-user-data-name-wrap">
                  <div class="hospital-content-user-data-name">
                    <h1>{{ hospitalData.user_name }}</h1>
                  </div>
                  <nuxt-link to="/aboutus/follow">
                    <div class="hospital-content-user-data-follow">
                      关注TA
                    </div>
                  </nuxt-link>
                </div>
                <div class="hospital-content-user-data-star">
                  <div v-if="hospitalData.evaluation_record_stat!==null" class="hospital-content-user-data-star">
                    <Stars :value="hospitalData.evaluation_record_stat.records[0].record_value" /> {{ hospitalData.evaluation_record_stat.records[0].record_value }}.0
                  </div>
                  <div v-else class="hospital-content-user-data-star">
                    <Stars :value="5" /> 5.0
                  </div>
                </div>
                <div class="hospital-content-hospital-address">
                  医院地址：{{ hospitalData.user_attributes.user_address }}
                </div>
              </div>
              <div class="hospital-content-user-data-right">
                <div class="case-counter">
                  <div class="case-num">
                    {{ hospitalData.user_statistic.case }}
                  </div>
                  <div class="case-text">
                    案例
                  </div>
                </div>
                <div class="appointment-counter">
                  <div class="case-num">
                    {{ hospitalData.user_statistic.place_total }}
                  </div>
                  <div class="case-text">
                    预约
                  </div>
                </div>
                <div class="follow-counter">
                  <div class="case-num">
                    {{ hospitalData.user_statistic.focus_total }}
                  </div>
                  <div class="case-text">
                    关注
                  </div>
                </div>
                <div class="popularity-counter">
                  <div class="case-num">
                    {{ hospitalData.user_statistic.fans_total }}
                  </div>
                  <div class="case-text">
                    粉丝
                  </div>
                </div>
              </div>
            </div>
            <div class="hospital-content-user-data-project">
              <div class="hospital-content-user-data-project-text">
                明星项目:
              </div>
              <div
                v-for="item in hospitalData.user_attributes.good_at"
                :key="item.id"
                class="hospital-content-user-data-project-item"
              >
                {{ item.name }}
              </div>
            </div>
          </div>
        </div>
        <div class="hospital-content-project-wrap">
          <div class="hospital-content-project-head">
            <div
              class="hospital-content-project-text"
              :class="{'active':active==='推荐项目'}"
              @click="tab('项目')"
            >
              推荐项目
            </div>
            <div
              v-if="caseNum"
              class="hospital-content-case"
              :class="{'active':active==='真人案例'}"
              @click="tab('案例')"
            >
              真人案例 ({{ caseNum }})
            </div>
          </div>
          <div
            v-if="active==='推荐项目'"
          >
            <div v-if="projectData.length" class="hospitale-content-project-item-wrap">
              <div
                v-for="item in projectData"
                :key="item.product_id"
                class="hospitale-content-project-item"
              >
                <ProjectList :project-data="item" />
              </div>
            </div>
            <div
              v-if="projectData.length===0"
              class="hospitale-noData"
            >
              <div class="hospitale-noData-content">
                <img
                  src="~assets/img/no-date.png"
                  alt=""
                >
                <div class="hospitale-noData-content-text">
                  这里什么都没有~
                </div>
              </div>
            </div>
          </div>
          <div
            v-if="active==='真人案例'"
            class="hospitale-content-case-item-wrap"
          >
            <DiaryList :diary-data="diaryData" />
          </div>
        </div>
      </div>
      <div class="hospital-hospital">
        <div class="hospital-hospital-title">
          <div class="hospital-hospital-title-text">
            医师团队
          </div>
          <div class="hospital-hospital-title-See">
            <!-- <div class="hospital-hospital-title-See-text">
              查看
            </div>
            <div class="hospital-hospital-title-See-icon" /> -->
          </div>
        </div>
        <div class="hospital-doctor">
          <div v-for="item in doctorData" :key="item.userid" class="hospital-doctor-item">
            <DoctorList :datas="item" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getHospitalData, getProjectRecommendData, getdiaryData, getDoctorTeamData } from '@/api/hospitalDetails'
import Stars from '@/components/stars'
import DiaryList from '@/components/diaryList'
import ProjectList from '@/components/doctorProjectList'
import DoctorList from '@/components/doctorList'
export default {
  components: {
    Stars,
    ProjectList,
    DiaryList,
    DoctorList
  },
  async asyncData({ isDev, route, store, env, params, query, req, res, redirect, error }) {
    const [hospitalData, projectData, diaryData, doctorData] = await Promise.all([
      getHospitalData(params.details).then(res => {
        return res.data
      }),
      getProjectRecommendData(params.details, 500).then(res => {
        return res.data
      }),
      getdiaryData(params.details, 500).then(res => {
        return res.data
      }),
      getDoctorTeamData(params.details).then(res => {
        return res.data
      })
    ])
    return {
      hospitalData,
      projectData,
      diaryData,
      doctorData
    }
  },
  data() {
    return {
      active: '推荐项目',
      caseNum: 0
    }
  },
  computed: {

  },
  created() {
    this.caseNum = this.diaryData.length
  },
  mounted() {

  },
  methods: {
    tab(val) {
      if (val === '案例') {
        this.active = '真人案例'
      } else {
        this.active = '推荐项目'
      }
    }
  },
  head() {
    return {
      title: `${this.hospitalData.user_name}_容猫医美`,
      meta: [
        { hid: 'description',
          name: 'description',
          content: `${this.hospitalData.user_remark}`
        }, {
          name: 'keywords', content: `${this.hospitalData.user_name},${this.hospitalData.user_name}怎么样,${this.hospitalData.user_name}案例,${this.hospitalData.user_name}在线咨询`
        }, {
          'http-equiv': 'mobile-agent', content: 'format=html5', url: `https://m.rongcat.com/hospital/${this.$route.params.details}`
        }
      ]
    }
  }
}
</script>
<style scoped lang="scss">
.hospital {
  width: 100%;
  background: rgba(246, 246, 246, 1);
  .hospital-wrap {
    width: 1190px;
    margin: 0 auto;
    padding-bottom: 30px;
    overflow: hidden;
    display: flex;
    position: relative;
  }
}
.hospital-content-head {
  width: 1190px;
  height: 54px;
  display: flex;
  align-items: center;
  margin: 0 auto;
  padding-top: 8px;
}
.hospital-content-head-text {
  font-size: 14px;
  font-weight: 400;
  color: rgba(51, 51, 51, 1);
  line-height: 20px;
  margin-left: 30px;
}
.hospital-content-head-text:hover {
  cursor: pointer;
}
.hospital-content-head-detils-text {
  font-size: 14px;
  font-weight: 400;
  color: rgba(80, 76, 255, 1);
  line-height: 20px;
}
.hospital-content-head-icon {
  width: 4px;
  height: 8px;
  background: url("~assets/img/right-icon.png") center center no-repeat;
  background-size: 100% 100%;
  margin-left: 10px;
  margin-right: 10px;
}
.hospital-content {
  width: 840px;
  border-radius: 4px;
  background: #fff;
}

.hospital-content-user-wrap {
  margin-top: 26px;
  margin-left: 28px;
  display: flex;
  .hospital-content-user-photo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
  }
  .hospital-content-user-consultation:hover{
    cursor: pointer;
  }
  .hospital-content-user-consultation {
    width: 100px;
    height: 24px;
    background: rgba(242, 241, 255, 1);
    border-radius: 15px;
    font-size: 14px;
    font-weight: 400;
    color: rgba(80, 76, 255, 1);
    line-height: 24px;
    text-align: center;
    margin-top: 17px;
  }
}
.hospital-content-user-data {
  width: 100%;
  margin-left: 14px;
  position: relative;
  .hospital-content-user-data-wrap {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
  .hospital-content-user-data-left {
    .hospital-content-user-data-name-wrap {
      display: flex;
      align-items: center;
    }
    .hospital-content-user-data-name {
      font-size: 16px;
      font-weight: 600;
      color: rgba(51, 51, 51, 1);
      line-height: 22px;
      h1{
        font-size: 16px;
      font-weight: 600;
      color: rgba(51, 51, 51, 1);
      line-height: 22px;
      }
    }
    .hospital-content-user-data-position {
      font-size: 12px;
      font-weight: 400;
      color: rgba(153, 153, 153, 1);
      line-height: 17px;
      margin-left: 10px;
    }
    .hospital-content-user-data-follow:hover{
      cursor: pointer;
    }
    .hospital-content-user-data-follow {
      width: 62px;
      height: 24px;
      background: rgba(82, 78, 255, 0.08);
      border-radius: 12px;
      font-size: 12px;
      font-weight: 400;
      color: rgba(80, 76, 255, 1);
      line-height: 24px;
      text-align: center;
      margin-left: 10px;
    }
    .hospital-content-user-data-star {
      font-size: 12px;
      font-weight: 400;
      color: rgba(153, 153, 153, 1);
      line-height: 17px;
      display: flex;
      align-items: center;
    }
    .hospital-content-hospital-address {
      width: 364px;
      font-size: 12px;
      font-weight: 400;
      color: rgba(153, 153, 153, 1);
      line-height: 17px;
      margin-top: 3px;
      flex-wrap: wrap;
      // overflow: hidden;
      // text-overflow: ellipsis;
      // white-space: nowrap;
    }
  }
  .hospital-content-user-data-right {
    display: flex;
    padding-right: 29px;
    .case-counter {
      text-align: center;
      margin-right: 60px;
      .case-num {
        font-size: 18px;
        font-weight: normal;
        color: rgba(51, 51, 51, 1);
        line-height: 22px;
      }
      .case-text {
        font-size: 11px;
        font-weight: 400;
        color: rgba(153, 153, 153, 1);
        line-height: 16px;
      }
    }
    .appointment-counter {
      text-align: center;
      margin-right: 60px;
      .case-num {
        font-size: 18px;
        font-weight: normal;
        color: rgba(51, 51, 51, 1);
        line-height: 22px;
      }
      .case-text {
        font-size: 11px;
        font-weight: 400;
        color: rgba(153, 153, 153, 1);
        line-height: 16px;
      }
    }
    .follow-counter {
      text-align: center;
      margin-right: 60px;
      .case-num {
        font-size: 18px;
        font-weight: normal;
        color: rgba(51, 51, 51, 1);
        line-height: 22px;
      }
      .case-text {
        font-size: 11px;
        font-weight: 400;
        color: rgba(153, 153, 153, 1);
        line-height: 16px;
      }
    }
    .popularity-counter {
      text-align: center;
      .case-num {
        font-size: 18px;
        font-weight: normal;
        color: rgba(51, 51, 51, 1);
        line-height: 22px;
      }
      .case-text {
        font-size: 11px;
        font-weight: 400;
        color: rgba(153, 153, 153, 1);
        line-height: 16px;
      }
    }
  }
}
.hospital-content-user-data-project {
  width: 670px;
  height: 44px;
  background: rgba(246, 246, 246, 1);
  box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.01);
  border-radius: 4px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  position: absolute;
  bottom:0;
  .hospital-content-user-data-project-text {
    margin-left: 18px;
    font-size: 12px;
    font-weight: 400;
    color: rgba(153, 153, 153, 1);
    line-height: 17px;
  }
  .hospital-content-user-data-project-item {
    font-size: 12px;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
    line-height: 17px;
    margin-left: 13px;
  }
}
.hospital-hospital {
  width: 340px;
  background: rgba(255, 255, 255, 1);
  border-radius: 4px;
  position: absolute;
  top: 0;
  right: 0;
  .hospital-hospital-title {
    width: 100%;
    height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(240, 240, 240, 1);
    .hospital-hospital-title-text {
      margin-left: 16px;
      font-size: 16px;
      font-weight: 400;
      color: rgba(51, 51, 51, 1);
      line-height: 22px;
    }
    .hospital-hospital-title-See {
      display: flex;
      font-size: 16px;
      font-weight: 600;
      color: rgba(216, 216, 216, 1);
      line-height: 22px;
      align-items: center;
      margin-right: 19px;
      .hospital-hospital-title-See-icon {
        width: 8px;
        height: 8px;
        background: url("~assets/img/more-icon.png") center center no-repeat;
        background-size: 100% 100%;
        margin-left: 4px;
      }
    }
  }
  .hospital-doctor{
    padding: 14px;
  }
  .hospital-doctor-item{
    margin-bottom:16px ;
  }
}

.hospital-content-project-wrap {
  margin-top: 20px;
  .hospital-content-project-head {
    width: 100%;
    height: 48px;
    border-top: 1px solid rgba(246, 246, 246, 1);
    border-bottom: 1px solid rgba(246, 246, 246, 1);
    display: flex;
    align-items: center;
  }
  .hospital-content-project-text {
    width: 112px;
    height: 50px;
    border-right: 1px solid rgba(246, 246, 246, 1);
    text-align: center;
    font-size: 14px;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
    line-height: 50px;
  }
  .hospital-content-project-text:hover {
    cursor: pointer;
  }
  .active {
    color: rgba(80, 76, 255, 1);
  }
}
.hospital-content-case {
  width: 112px;
  height: 50px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(51, 51, 51, 1);
  line-height: 50px;
  text-align: center;
}
.hospital-content-case:hover {
  cursor: pointer;
}
.hospitale-content-project-item-wrap {
  display: flex;
  flex-wrap: wrap;
  padding: 10px;
  .hospitale-content-project-item{
    margin-right: 7px;
  }
}
.hospitale-content-case-item-wrap {
  margin-top: 20px;
  margin-left: 20px;
}
.hospitale-noData {
  width: 840px;
  height: 790px;
  background: rgba(255, 255, 255, 1);
  border-radius: 4px;
  margin-top: 10px;
  position: relative;
  .hospitale-noData-content {
    width: 242px;
    height: 210px;
    position: absolute;
    left: 50%;
    top:150px;
    margin-left: -121px;
    > img {
      width: 242px;
      height: 191px;
    }
    .hospitale-noData-content-text{
      font-size:14px;
      font-family:PingFangSC-Regular,PingFang SC;
      font-weight:400;
      color:rgba(153,153,153,1);
      line-height:20px;
      text-align: center;
    }
  }
}
</style>
